#include "effect.h"
#include "effect/BombEffect.h"
#include "effect/npc1bomb.h"
#include "effect/npc2bomb.h"
#include "effect/npc3bomb.h"
#include "effect/npc4bomb.h"

namespace fireplane{

	Effect::Effect(EffectType type):
		_type(type)
	{}

	Effect::~Effect()
	{}

	Effect* Effect::createEffect(CreateCmd* cmd){
		Effect* effect = NULL;

		switch(cmd->_id){
		case ET_bomb0:
		case ET_bomb1:
			{
				CreateBomb0OrBomb1* tcmd = (CreateBomb0OrBomb1*)cmd;

				effect = new BombEffect(tcmd->_id);
				effect->autorelease();
				effect->init(tcmd);

				_all_effect_parent->addChild(effect);
			}
			break;

		case ET_bomb2:
			{
				CreateBomb2* tcmd = (CreateBomb2*)cmd;
				effect = new BombEffect(tcmd->_id);
				effect->autorelease();
				effect->init(tcmd);

				_all_effect_parent->addChild(effect);
			}
			break;
case ET_npc1:
			{
				CreateNpc1Bomb* tcmd = (CreateNpc1Bomb*)cmd;
				effect = new Npc1Bomb(tcmd->_id);
				effect->autorelease();
				effect->init(tcmd);

				_all_effect_parent->addChild(effect);
			}
			break;
		case ET_npc2:
			{
				CreateNpc2Bomb* tcmd = (CreateNpc2Bomb*)cmd;
				effect = new Npc2Bomb(tcmd->_id);
				effect->autorelease();
				effect->init(tcmd);

				_all_effect_parent->addChild(effect);
			}
			break;
		case ET_npc3:
			{
				CreateNpc3Bomb* tcmd = (CreateNpc3Bomb*)cmd;
				effect = new Npc3Bomb(tcmd->_id);
				effect->autorelease();
				effect->init(tcmd);

				_all_effect_parent->addChild(effect);
			}
			break;
		case ET_npc4:
			{
				CreateNpc4Bomb0* tcmd = (CreateNpc4Bomb0*)cmd;
				effect = new Npc4Bomb(tcmd->_id);
				effect->autorelease();
				effect->init(tcmd);

				_all_effect_parent->addChild(effect);
			}
			break;

		case ET_npc41:
			{
				CreateNpc4Bomb0* tcmd = (CreateNpc4Bomb0*)cmd;
				effect = new Npc4Bomb1(tcmd->_id);
				effect->autorelease();
				effect->init(tcmd);

				_all_effect_parent->addChild(effect);
			}
			break;
		}

		return effect;
	}

	void Effect::init(CreateCmd* pos)
	{}

	CCNode* Effect::_all_effect_parent = NULL;

}